pragma circom 2.0.0;

include "node_modules/circomlib/circuits/comparators.circom";
include "node_modules/circomlib/circuits/gates.circom";

template RollupVerifier() {
    signal input balance_from;
    signal input new_balance_from;
    signal input to_address;
    signal input amount;
    
    signal output valid;
    
    // 检查余额充足
    component gt = GreaterEq(252);
    gt.in[0] <== balance_from;
    gt.in[1] <== amount;
    
    // 检查新余额正确
    component add = Add();
    add.a <== new_balance_from;
    add.b <== amount;
    add.out === balance_from;
    
    // 检查接收地址有效
    component neq = IsZero();
    neq.in <== to_address;
    neq.out === 0;
    
    valid <== gt.out;
}

component main = RollupVerifier(); 